/*
 * © 2010 Autodata Solutions Company. All Rights Reserved
 * This source code is the confidential and proprietary information of Autodata Solutions Company.
 * The user shall not, in whole or in part, copy, publish, disclose or make any use of this source code
 * without the prior written consent of Autodata Solutions Company.
 */
Ext.ns('net.autodata.modelwalk.ModelWalkView');
(function () {
	var DQ = Ext.DomQuery;
	
	/**
	 * Default View for the net.autodata.modelwalk.ModelWalkPanel
	 * @class ModelWalkView
	 * @extends net.autodata.AbstractView
	 * @namespace net.autodata.modelwalk
	 */
	var View = Ext.extend(net.autodata.AbstractView, {
		
		cls: '',
		
		/**
		 * @property templates
		 * @type Object
		 */
		templates: undefined,
		
		//override the abstract constructor to allow this object to be created
		constructor: function ()
		{
			View.superclass.ctor.apply(this, arguments);
		},
		
		/**
		 * @method initTemplates
		 */
		initTemplates: function ()
		{
			var tpls = this.templates || {};			
			
			if (tpls.mainTpl === undefined) {
				tpls.mainTpl = new Ext.Template(
					'<div class="modelwalk-view {viewCls}">',
						'<table border="0" cellpadding="0" cellspacing="0">',
							'<tr>',
								'<td>' + ASC.message('net.autodata.modelwalk.label.modelYear') + '</td>',
								'<td class="modelyear-wrap"></td>',
							'</tr>',
							'<tr>',
								'<td>' + ASC.message('net.autodata.modelwalk.label.make') + '</td>',
								'<td class="make-wrap"></td>',
							'</tr>',
							'<tr>',
								'<td>' + ASC.message('net.autodata.modelwalk.label.model') + '</td>',
								'<td class="model-wrap"></td>',
							'</tr>',
							'<tr>',
								'<td>' + ASC.message('net.autodata.modelwalk.label.trim') + '</td>',
								'<td class="trim-wrap"></td>',
							'</tr>',
						'</table>', 
					'</div>',
					{
						compiled: true,
						disableFormats: true
				});
			}
			
			this.templates = tpls;
			
			View.superclass.initTemplates.apply(this, arguments);
		},
		
		/**
		 * @method render
		 */
		render: function ()
		{
			var mw = this.component;
			var body = mw.el.dom;
			
			this.templates.mainTpl.overwrite(body, this.getTemplateArgs());
			
			mw.modelYear.render(DQ.selectNode('.modelyear-wrap', body));
			mw.make.render(DQ.selectNode('.make-wrap', body));
			mw.model.render(DQ.selectNode('.model-wrap', body));
			mw.trim.render(DQ.selectNode('.trim-wrap', body));
		},
		
		getTemplateArgs: function ()
		{
			return { viewCls: this.cls || ''};
		}
	});
	
	net.autodata.modelwalk.ModelWalkView = View;
})();